<template>
  <div class="report-detail" >
    <el-page-header @back="goBack" content="详情页面"></el-page-header>
    <div id="detail-dynamic">
      <div>
        <p>发布时间:{{dynamic.createTime|formatDate}}</p>
        <p>动态内容:</p>
        <div style="width: 400px;word-break: break-all;min-height: 100px;">
          {{dynamic.context}}
        </div>
      </div>
      <div>
        <h4 style="margin: 0">图片</h4>
        <img v-for="item in img" :src="'data:image/png;base64,'+item" alt="">
      </div>

    </div>
    <p>举报人:{{userName}}</p>
    <p>举报说明:{{report.content}}</p>

    <div v-if="report.state!=0" style="display: flex">
      <h3>审核结果:</h3>
      <h3 style="color: orange" v-if="report.state==1">举报成功</h3><h3 v-else style="color: orange">举报失败</h3>
    </div>
    <div v-else>
      <el-button @click="success" type="success">通过举报</el-button>
      <el-button @click="fail" type="danger">驳回举报</el-button>
    </div>

  </div>

</template>

<script>
import {failReport, getArchives, getDeal, passReport} from "@/network/admin";

export default {
  name: "dynamicReDetails",
  data(){
    return{
      id:0,
      dynamic:{},
      report:{},
      userName:'',
      img:[]
    }
  },
  created() {
    let id=this.$route.query.id
    this.id=id
    getDeal(id).then(res=>{
      console.log(res)
      this.dynamic=res.data.extend.dynamic
      this.report=res.data.extend.report
      this.img=res.data.extend.fileList
      this.getUserName(this.report.type,this.report.uid)
    })
  },
  methods:{
    getUserName(type,uid){
      getArchives(type,uid).then(res=>{
        let data=res.data.extend.object
        this.userName=data.studentName||data.companyName||data.universityName
      })
    },
    fail(){
      failReport(this.id).then(res=>{
        this.$message.success(res.data.msg)
        this.goBack()
      })
    },
    success(){
      passReport(this.id).then(res=>{
        this.$message.success(res.data.msg)
        this.goBack()
      })
    },
    goBack(){
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="stylus" scoped>
#detail-dynamic
  margin-top 20px
  padding 0 10px
  width 100%
  border 2px solid orange
  display flex
  &>div
    width 50%
    & img
      width 100px
      height 100px
      margin-right 5px
</style>
